﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace com.iot.core.util
{
    public class DateUtil
    {
        public static readonly string ShortDateFormatString = "yyyy-MM-dd"; 
        public static readonly string DateFormatString = "yyyy-MM-dd HH:mm:ss";
        public static readonly DateTime First = new DateTime(2000, 1, 1);

        public static string DayOfWeek(DateTime dt)
        { 
            switch (dt.DayOfWeek.ToString("D"))
            {
                case "0":
                    return "星期日 ";
                case "1":
                    return "星期一 ";
                case "2":
                    return "星期二 ";
                case "3":
                    return "星期三 ";
                case "4":
                    return "星期四 ";
                case "5":
                    return "星期五 ";
                case "6":
                    return "星期六 ";
            }
            return "";
        }
        public static string NowStr(string Format="")
        {
            if (string.IsNullOrEmpty(Format))
            {
                Format = DateFormatString;
            }
            return DateTime.Now.ToString(Format);
        }
        public static string TodayStr(string Format = "")
        {
            if (string.IsNullOrEmpty(Format))
            {
                Format = ShortDateFormatString;
            }
            return DateTime.Now.ToString(Format);
        }
    }
}
